{extend name="common/layout" /}
{block name="main"}
<div class="admin-main layui-anim layui-anim-upbit">

    <div class="padding30">
        <h3 class="page-box-title">{:lang('User Group List')}</h3>
        <div style="clear: both;"></div>
    </div>
    <div class="" id="_listBox">
                <div style="text-align: right;"><a href="{:url('groupAdd')}"  class="layui-btn layui-btn-normal layui-btn-add borderrad5 " title="{:lang('Add')}" ><i class="icon icon-plus"></i></a></div>

    <table class="layui-table" id="list" lay-filter="list"></table> 
</div>
</div>
{/block}
{block name="footer"}
<script type="text/html" id="action">
    <a href="{:url('groupAccess')}?id={{d.group_id}}" class="">{:lang('Setting Rules')}</a> |
    <a href="{:url('groupEdit')}?id={{d.group_id}}" class="">{:lang('Edit')}</a> | 
    {{#  if(d.is_sys === 1){ }}
    <a class=" layui-btn-disabled" >{:lang('Delete')}</a>
    {{# }else{  }}
    <a class="" lay-event="del">{:lang('Delete')}</a>
    {{#  } }} 
</script>
<script>

    layui.use('table', function() {
        var table = layui.table,$ = layui.jquery;
        table.render({
            elem: '#list',
            url: '{:url("adminGroup")}',
            method:'post',
            cols: [[
                {field:'group_id', title: '{:lang("id")}',width:"10%", fixed: true,sort: true,align:"center"},
                {field:'title', title: "{:lang('Group Name')}", width:"20%"},
                {field:'addtime', title: "{:lang('Add Time')}", width:"20%",sort: true},
                {width:"45%", align:'center',toolbar:'#action',align:"right"}
            ]]
        });
        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('Are you sure you want to delete it?', function(index){
                    loading =layer.load(1, {shade: [0.1,'#fff']});
                    $.post("{:url('groupDel')}",{id:data.group_id},function(res){
                        layer.close(loading);
                        layer.close(index);
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                });
            }
        });
    });
</script>
{/block}